#include "stdafx.h"


CPlayerManager::CPlayerManager()
{
	m_MapPlayer.clear();
}

CPlayerManager::~CPlayerManager()
{
	m_MapPlayer.clear();
}

CPlayerManager* CPlayerManager::instance()
{
	static CPlayerManager inst;
	return &inst;
}

void CPlayerManager::online(CPlayer* player)
{
	if (!player)
		return;
	if (m_MapPlayer.find(player->m_fd) != m_MapPlayer.end())
		m_MapPlayer[player->m_fd] = player;
	else
		m_MapPlayer.insert(std::make_pair(player->m_fd, player));
}

void CPlayerManager::offline(CPlayer* player)
{
	if (!player)
		return;
	m_MapPlayer.erase(player->m_fd);
	delete(player);
	player = NULL;
}
